import java.util.Scanner;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class code3 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        char[] a = in.next().toCharArray();
        char[] b = in.next().toCharArray();

        int n = a.length;
        int m = b.length;
        int[][] dp = new int[n+1][m+1];
        //初始化
        for(int i=0;i<=n;i++) dp[i][0]=i;
        for(int i=0;i<=m;i++) dp[0][i]=i;

        for(int i=1;i<=n;i++) {
            for(int j=1;j<=m;j++) {
                if(a[i-1]==b[j-1]) dp[i][j]=dp[i-1][j-1];
                else {
                    dp[i][j]=Math.min(Math.min(dp[i-1][j],dp[i][j-1]),dp[i-1][j-1])+1;
                }
            }
        }

        System.out.print(dp[n][m]);

    }
}